﻿using System;
using System.Collections.Generic;
using System.Composition;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace System.Architecture
{
    public interface IPersistedObject
    {
        void Load();
        void Save();
    }

    [MetadataAttribute]
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
    public class PersistedAttribute : ExportAttribute
    {
        public string Store { get; set; }

        public PersistedAttribute()
            : base(typeof(IPersistedObject))
        {
        }

        public override bool Equals(object obj)
        {
            var v = (PersistedAttribute)obj;
            if (v == null)
                return false;

            return this.Store.Equals(v.Store);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
    }

}
